#include <string>
#include <fstream>
#include <iostream>
#include "LoadTetFile.h"
#include "MeshRefine.h"

//#define TRIA_TEST

int main(int argc, char* argv[])
{
    std::vector<Node> vR;
    std::vector<Tria> vTria;
    std::vector<Tetr> vTetr;
    std::vector<bool> vRefine;

    if (argc < 2) {
        std::cout << "Error: No input mesh file." << std::endl;
        return -1;
    }
    auto sName = std::string(argv[1]);

#ifdef TRIA_TEST
    bool bOk = fn_LoadGdmFile(sName, vR, vTria);
    if (!bOk) {
        std::cout << "Error: Load mesh file failed." << std::endl;
        return -2;
    }
    fn_MarkGdmElem(sName, vR, vTria, vRefine);
    RefineMesh(vR, vTria, vRefine);
    fn_OutputMesh(sName, vR, vTria);
#else
    bool bOk = fn_LoadTetFile(sName, vR, vTetr);
    if (!bOk) {
        std::cout << "Error: Load mesh file failed." << std::endl;
        return -2;
    }
    fn_MarkTetElem(sName, vR, vTetr, vRefine);
    RefineMesh(vR, vTetr, vRefine);
    fn_OutputMesh(sName, vR, vTetr);

    fn_OutBoudMsh(sName, vR, vTetr);
#endif

    return 0;
}
